﻿using System.Collections.Generic;
using System;
using Microsoft.Xna.Framework;

namespace Ramparts
{
    public class StatefulGameComponent : GameComponent
    {

        // States
        public Dictionary<int, I_State> states;
        public Dictionary<bool, int> state_map;
        public int currentState;
        public bool usingState;
      
        public StatefulGameComponent(Vector2 position, SceneManager inSceneManager)
        {
            states = new Dictionary<int,I_State>();
            currentState = 0;
            usingState = false;
            this.sceneManager = inSceneManager;
            this.position = position;

        }

        public override void Update(Microsoft.Xna.Framework.GameTime gameTime)
        {
            getCurrentState().update(gameTime);
        }

        public override void Draw()
        {
            states[currentState].draw();
        } 

        public virtual void addState(int id, I_State state)
        {
            states.Add(id, state);
        }

        public virtual void removeState(int id)
        {
            states.Remove(id);
        }

        public virtual I_State getCurrentState()
        {
            if (states.Count != 0)
                return states[currentState];
            else
                return null;
        }

        public virtual void setCurrentStateId(int stateid)
        {
            currentState = stateid;
        }

        public virtual int getCurrentStateId()
        {
            return currentState;
        }
    }
}
